package org.example.campus_sys_backend.controller;

import org.example.campus_sys_backend.model.TeacherInfo;
import org.example.campus_sys_backend.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    public TeacherService teacherService;
    @RequestMapping("/add")
    public Boolean addTeacher(TeacherInfo teacherInfo){
        if (teacherInfo != null){
            teacherService.insertTeacher(teacherInfo);
            return true;
        }
        return false;
    }
    @RequestMapping("/findid")
    public TeacherInfo selectTeacher(Integer id){
        if (id > 0){

            return teacherService.queryUserById(id);
        }
        return null;
    }
    @RequestMapping("/findname")
    public TeacherInfo selectTeacher2(String teacherName){
        if (teacherName != null){
            return teacherService.queryUserByName(teacherName);
        }
        return null;
    }
}
